package com.bot.nft.module.dc.api;

import com.bot.common.pojo.CommonResult;
import com.bot.nft.core.enums.chain.ChainLogEnum;
import com.bot.nft.core.util.NftCodeUtil;
import com.bot.nft.module.dc.domain.DcNftCert;
import com.bot.nft.module.dc.domain.vo.DcNftCertVo;
import com.bot.nft.module.dc.mapper.DcNftCertMapper;
import com.bot.nft.module.dc.service.IDcNftCertService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 藏品证书前端控制器
 * </p>
 *
 * @author zhangkaige
 * @since 2024-01-24
 */
@RestController
@RequestMapping("/app/cert")
public class AppDcNtfCertController {

    @Resource
    private IDcNftCertService nftCertService;
    @Resource
    private DcNftCertMapper dcNftCertMapper;

    @GetMapping("/{certId}/getNftCert.do")
    public CommonResult<DcNftCertVo> queryCertList(@PathVariable String certId) {
        DcNftCertVo nftCert = nftCertService.getNftCertVo(certId);
        return CommonResult.data(nftCert);
    }

    @GetMapping("/test/genNftCert.do")
    public CommonResult<String> genNftCert() {
        //藏品
        String nft1 = "1729408023135305728";
        String nft2 = "1729408023135305729";
        //会员
        String mb1 = "1730107866586157056";
        String mb2 = "1734099508083220480";
        String mb3 = "1742540461290721280";
        //业务类型
        Integer airdrop = ChainLogEnum.BUSINESS_AIRDROP.getValue();

        DcNftCert nftCert = nftCertService.genCert(nft1, mb1, airdrop);
        dcNftCertMapper.insert(nftCert);
        return CommonResult.ok();
    }

    @GetMapping("/test/transferNftCert.do")
    public CommonResult<String> transferNftCert() {
        //藏品
        String cert1 = "1753373201176993792";
        //会员
        String mb2 = "1734099508083220480";
        //业务类型
        Integer airdrop = ChainLogEnum.BUSINESS_MARKET_PURCHASE.getValue();

        nftCertService.transferCert(cert1, mb2,airdrop);

        return CommonResult.ok();
    }

    @GetMapping("/code/getNftCert.do")
    public CommonResult<String> code() {
        NftCodeUtil.setCodeList("1729408023135305728", 1000);
        NftCodeUtil.setCodeList("1729408023135305729", 1000);

        return CommonResult.ok();
    }


}
